package com.koron.order.overhaulExperimentRel.controller;

import com.github.pagehelper.PageInfo;
import com.koron.bean.base.Response;
import com.koron.bean.query.PageQuery;
import com.koron.common.core.config.ThreadLocalContext;
import com.koron.order.overhaulExperimentRel.bean.po.OverhaulExperimentRelPo;
import com.koron.order.overhaulExperimentRel.service.OverhaulExperimentRelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.koron.ebs.mybatis.ADOConnection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 大修工单与试验工单的关联表(OverhaulExperimentRel)表控制层
 *
 * @author zhouj
 * @since 2022-04-21 11:20:49
 */
@Api(tags = "大修工单与试验工单的关联表(OverhaulExperimentRel)")
@RestController
@RequestMapping("/overhaulExperimentRel/")
public class OverhaulExperimentRelController {

    @Autowired
    private OverhaulExperimentRelService overhaulExperimentRelService;

    private String getCurrDs() {
        return ThreadLocalContext.get().getCurrDs();
    }

    @ApiOperation(value = "新增或修改大修工单与试验工单的关联表")
    @PostMapping("insertOrUpdate")
    public Response<Integer> insertOrUpdate(@RequestBody OverhaulExperimentRelPo overhaulExperimentRel) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), overhaulExperimentRelService, "insertOrUpdate", Integer.class, overhaulExperimentRel));
    }

    @ApiOperation(value = "新增大修工单与试验工单的关联表")
    @PostMapping("insert")
    public Response<Integer> insert(@RequestBody OverhaulExperimentRelPo overhaulExperimentRel) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), overhaulExperimentRelService, "insert", Integer.class, overhaulExperimentRel));
    }

    @ApiOperation(value = "批量新增大修工单与试验工单的关联表")
    @PostMapping("insertBatch")
    public Response<Integer> insertBatch(@RequestBody List<OverhaulExperimentRelPo> overhaulExperimentRelList) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), overhaulExperimentRelService, "insertBatch", Integer.class, overhaulExperimentRelList));
    }

    @ApiOperation(value = "根据id更新大修工单与试验工单的关联表")
    @PutMapping("update")
    public Response<Integer> update(@RequestBody OverhaulExperimentRelPo overhaulExperimentRel) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), overhaulExperimentRelService, "update", Integer.class, overhaulExperimentRel));
    }

    @ApiOperation(value = "根据id删除大修工单与试验工单的关联表")
    @DeleteMapping("deleteById")
    public Response<Integer> deleteById(Integer id) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), overhaulExperimentRelService, "deleteById", Integer.class, id));
    }

    @ApiOperation(value = "根据大修工单id+试验工单ID 删除大修工单与试验工单的关联表")
    @DeleteMapping("deleteByOverhaulId")
    public Response<Integer> deleteByOverhaulId(OverhaulExperimentRelPo overhaulExperimentRel) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), overhaulExperimentRelService, "deleteByOverhaulId", Integer.class, overhaulExperimentRel));
    }

    @ApiOperation(value = "根据id查询大修工单与试验工单的关联表")
    @GetMapping("queryById")
    public Response<OverhaulExperimentRelPo> queryById(Integer id) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), overhaulExperimentRelService, "queryById", OverhaulExperimentRelPo.class, id));
    }

    @ApiOperation(value = "不分页查询大修工单与试验工单的关联表列表")
    @GetMapping("queryList")
    public Response<List> queryList(OverhaulExperimentRelPo relPo) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), overhaulExperimentRelService, "queryList", List.class, relPo));
    }

    @ApiOperation(value = "分页查询大修工单与试验工单的关联表列表")
    @GetMapping("queryPageList")
    public Response<PageInfo> queryPageList(OverhaulExperimentRelPo queryPo, PageQuery pageQuery) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), overhaulExperimentRelService, "queryPageList", PageInfo.class, queryPo, pageQuery));
    }

}
